import { post, get } from '@/http/request';

export type LoginRequest = {
    username: string;
    password: string;
};

export type reLoginRequest = {
    accessToken: string;
};

export type LoginResponse = {
    username: string;
    roles: string[];
    accessToken: string;
};

/**
 * 用户登录
 * @param data 参数
 * @returns 用户信息
 */
export const userLogin = async (data?: LoginRequest) => {
    return post<LoginResponse>({}, '/login', data);
};

/**
 * 重新获取用户信息
 * @param data token
 * @returns 用户信息
 */
export const refreshUserInfo = async (data?: reLoginRequest) => {
    return post<LoginResponse>({}, '/getUserInfo', data);
};

/**
 * 获取用户列表
 * @returns 用户列表
 */
export const getUserList = async () => {
    return get({}, '/getUserList');
};
